import 'package:flutter_study/flutter/_16App%E6%B5%8B%E8%AF%95/unittest_counter.dart';
import 'package:flutter_study/flutter/_16App%E6%B5%8B%E8%AF%95/unittest_math_utils.dart';
import 'package:flutter_test/flutter_test.dart';

/// 单元测试
void main() {
  test('math utils file sum test', () {
    final result = sum(1, 2);
    // 结果 期望值
    expect(result, 3);
  });

  // 多个方法一起测试
  group('math file test', () {
    test('math utils file sum test', () {
      final result = sum(1, 2);
      // 结果 期望值
      expect(result, 3);
    });

    test('math utils file div test', () {
      final result = div(4, 2);
      // 结果 期望值
      expect(result, 2);
    });
  });

  group('counter class test', () {
    // 所有方法引用同一对象，按照方法声明顺序执行
    Counter counter;
    // 初始化操作,所有测试开始前执行
    setUpAll(() {
      counter = Counter();
    });

    test('counter init value', () {
      expect(counter.count, 0);
    });

    test('counter increment test', () {
      counter.increment();
      expect(counter.count, 1);
    });

    test('counter decrement test', () {
      counter.decrement();
      expect(counter.count, 0);
    });
  });
}
